﻿using BigEgg.Framework.Foundation;
using BigEgg.Framework.UnitTesting;
using FMStudio.Domain.Properties;
using FMStudio.Domain.SQLite;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Globalization;

namespace FMStudio.Domain.SQLite.Test
{
    [TestClass]
    public class UseTypeCategoryTest
    {
        [TestMethod]
        public void GeneralUseTypeCategoryTest()
        {
            UseTypeCategory useTypeCategory = new UseTypeCategory();

            Assert.IsNotNull(useTypeCategory.ID);
            Assert.AreEqual("", useTypeCategory.Name);

            useTypeCategory.Name = "Food";

            Assert.AreEqual("", useTypeCategory.Validate());
        }
        
        [TestMethod]
        public void UseTypeCategoryNameValidationTest()
        {
            UseTypeCategory useTypeCategory = new UseTypeCategory();

            Assert.AreEqual(string.Empty, useTypeCategory.Name);
            Assert.AreEqual(Resources.UseTypeCategoryNameMandatory, useTypeCategory.Validate("Name"));

            useTypeCategory.Name = TestHelper.CreateString('A', 99);
            Assert.AreEqual("", useTypeCategory.Validate("Name"));
            useTypeCategory.Name = TestHelper.CreateString('A', 100);
            Assert.AreEqual("", useTypeCategory.Validate("Name"));
            useTypeCategory.Name = TestHelper.CreateString('A', 101);
            Assert.AreEqual(
                string.Format(CultureInfo.CurrentCulture, Resources.UseTypeCategoryNameMaxLength, "Name", 100)
                , useTypeCategory.Validate("Name"));
        }
    }
}
